{extend name="base" /} {block name="body"}
<div class="layui-body">
	<div class="navbar">
		<a><cite>广告管理</cite></a>&nbsp;<span class="layui-box">&gt;</span>
		<a href=""><cite>广告列表</cite></a>
	</div>
	<!--tab标签-->
	<div class="layui-tab layui-tab-brief">
		<div>
			<a href='add_ads' class="layui-btn  layui-btn-normal">添加广告</a>
		</div>
		<div class="layui-tab-content">
			<table class="layui-table layui-form">
				<thead>
					<tr>
						<th>标题</th>
						<th>广告图片</th>
						<th>广告链接</th>
						<th>广告类型</th>
						<th>添加时间</th>
						<th>修改时间</th>
						<th>编辑广告</th>
					</tr>
				</thead>
				<tbody>
					<form id="listForm">
						{foreach name="list" item="vo"}
						<tr>

							<td style="width:12%">{$vo.title}</td>
							<td><img style="width: 50px;height: 50px;" src="{$vo.thumb}" /></td>
							<td style="width:15%">{$vo.url}</td>
							<td>
								{$vo.type|get_ads}
							</td>
							<td>{$vo.add_time}</td>
							<td>{$vo.update_time}</td>
							<td>
								<a class="layui-btn layui-btn-status " href="edit_ads?id={$vo.id}"><i class="fa fa-edit"></i> 编辑</a>
								<a onclick='del({$vo.id})' class="layui-btn  layui-btn-error layui-btn-status">删除</a>

							</td>
						</tr>
						{/foreach}
					</form>
				</tbody>
			</table>
			{$list->render()}

		</div>

	</div>
</div>

<script src="/public/static/layui/layui.js" charset="utf-8"></script>
<script>
	function del(obj) {
		layer.confirm('确定要删除吗？', {
			btn: ['确认', '取消'],
		}, function(index) {
			$.ajax({
				type: "post",
				url: "{:url('ads/delete')}",
				data: {
					id: obj
				}, //表单数据
				success: function(data) {
					layer.msg(data.msg, function(index) {
						location.href = data.url;

					});

				}
			});

		});

	}
</script>
{/block}